# -*- coding: utf-8 -*-
from django.http import HttpResponse

def hello(request):
    return  HttpResponse("Hello world!世界，你好！")

import datetime
def current_time(request):
    now = datetime.datetime.now()
    html = "<html><body>it's time now is:%s</body></html>" %now
    return HttpResponse(html)


from django.http import Http404
def time_plus(request,offset):
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()
    if offset>24:
        html = "<html><body>时区参数必须在0-24之间，您输入的数值是%s</body></html>" %offset
    else:
        dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
        html = "<html><body>在第 %s 时区, 现在时间是 %s.</body></html>" % (offset, dt)
    return HttpResponse(html)
